﻿/*----------------------------------------------------------------
    // Copyright (C) 2009 江苏华招网
    // 版权所有。 
    // 作者：
    //

    //
    // 修改标识：
    // 修改描述：
    //
    // 修改标识：
    // 修改描述：
    //
    // 审核人：
    // 审核时间：
    // 审核说明：
 //----------------------------------------------------------------*/
using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HZ.DrugTrade.BLLFactory;
using HZ.DrugTrade.IBLL;
using HZ.DrugTrade.Model;
using HZ.DrugTrade.Model.Enum;


namespace HZ.DrugTrade.Web.Admin.DrugLibManage
{
    public partial class HospitalLoginPrice :BasePage
    {
        public HospitalLoginPrice()
        {
            this.ModuleNo = Module.采购项目管理.ToString();//权限
            this.PageOperateType = OperateType.查看产品填报.ToString();
        }
        IBLL_HospitalLoginPriceGoods ih = Factory.BLL_HospitalLoginPriceGoods();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                SetBind();
            }
        }

        /// <summary>
        /// 绑定符合条件的采购明细
        /// </summary>
        private void SetBind()
        {
             int totalCount;
            IList<Model.View.HospitalLoginPriceGoods> purchaseOrderDetailList = ih.getGoodsToTalByWhere(GetQuery(), AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out totalCount);
            AspNetPager1.RecordCount = totalCount;
            gvwNoConfirm.PageSize = AspNetPager1.PageSize;
            gvwNoConfirm.DataSource = purchaseOrderDetailList;
            gvwNoConfirm.DataBind();
        }
        public Model.Query.HospitalLoginPriceGoods GetQuery()
        {
            Model.Query.HospitalLoginPriceGoods where = new HZ.DrugTrade.Model.Query.HospitalLoginPriceGoods();
            if (txtGoodsID.Text != "")
            {
                if (Fun.IsInt(txtGoodsID.Text.Trim()))
                {
                    where.GoodsID = txtGoodsID.Text.Trim();//流水号

                }
                else
                {
                    HZ.Web.WebUtil.Alert("请输入整数编号！");

                }
            }

            where.GoodsName = txtGoodsName.Text.Trim();//产品名称
            where.Material = txtMaterial.Text.Trim();//材质
            where.Outlookc = txtOutLook.Text.Trim();
            where.CompanyName_SC = txtCompanyName_Sc.Text.Trim();//生产企业
            return where;
        }

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnQuery_Click(object sender, EventArgs e)
        {
            AspNetPager1.CurrentPageIndex = 1;
            SetBind();
        }

        /// <summary>
        /// 翻页
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void AspNetPager1_OnPageChanged(object sender, EventArgs e)
        {
            SetBind();
        }


        /// <summary>
        /// 导出2009-11-25
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnExport_Click(object sender, EventArgs e)
        {
            //int totalcount = 0;
            //IBLL_ProcurementBasic ipb = Factory.BLL_ProcurementBasic();
            //System.Data.DataTable dt = ipb.GetProcureCatalogDTByWhere(getw, 1, 0, out totalcount);
            ////HZ.Data.ModelConvert.GetDataTableFromModel(procureCatalogList);

            //HZ.Excel.ExcelHelper.ExportDataForWeb(dt, gvwNoConfirm, this);
            //int totalCount = 0;
            //IList<Model.View.HospitalLoginPriceGoods> purchaseOrderDetailList = ih.getGoodsToTalByWhere(GetQuery(), 1, 0, out totalCount);
            //System.Data.DataTable tb = HZ.Data.ModelConvert.GetDataTableFromModel(purchaseOrderDetailList);
            //HZ.Excel.ExcelHelper.ExportDataForWeb(tb, gvwNoConfirm);
            HZ.DrugTrade.Model.Query.HospitalLoginPriceGoods hospitalLoginPriceGoods = GetQuery();
            string where = HZ.DrugTrade.DAL2.DAL_Helper.GetWhereCondition<HZ.DrugTrade.Model.Query.HospitalLoginPriceGoods>(hospitalLoginPriceGoods, true);
            string sql = string.Format(@"SELECT GoodsID 产品编号,GoodsName 产品名称,Outlookc 规格型号,Material 材质,Unit 最小计量单位,PackUnit 包装单位,
                                         CompanyName_SC 生产企业,minPrice 填报最低价格,minHospitalName 填报最低医疗机构,MaxPrice 填报最高价格,
                                         MaxHospitalName 填报最高医疗机构 FROM TB_HospitalLoginPriceGoods A LEFT JOIN TB_HospitalLoginPriceTotal  B ON A.GOODSID=B.GOODSIDS WHERE 1=1 {0}", where);
            HZ.DrugTrade.BLL.ExcelHelper.ExportByWeb(HZ.Data.DbHelperFactory.Create().ExecuteTable(sql), "", "医疗机构确认价格汇总.xls");
        }

        protected void hzOpen_Click(object sender, EventArgs e)
        {
            if (ih.OpenCountryOver())
            {
                PageError("县级以上医疗机构开启成功！",this.ReturnUrl);
            }
            else
            {
                PageError("县级以上医疗机构开启失败，请与管理员联系！", this.ReturnUrl);
            }
        }

        protected void HZClose_Click(object sender, EventArgs e)
        {
            if (ih.CloseCountryOver())
            {
                PageError("县级以上医疗机构关闭成功！", this.ReturnUrl);
            }
            else
            {
                PageError("县级以上医疗机构关闭失败，请与管理员联系！", this.ReturnUrl);
            }
        }

        protected void HZCalbtn_Click(object sender, EventArgs e)
        {
            if (ih.CalHospitalLoginPrice()==1)
            {
                PageError("计算汇总医疗机构填报价格成功！", this.ReturnUrl);
            }
            else
            {
                PageError("计算汇总医疗机构填报价格失败，请重试！", this.ReturnUrl);
            }
        }


       
    }
}
